/**	Livre_.java
*	ImageJ plug-in that finds all primes <32000 and displays them in an image
*/

import ij.*;
import ij.plugin.PlugIn;
import ij.process.*;
import ij.gui.*;
import java.awt.*;

public class Livre_ extends ImagePlus implements PlugIn {

	short[] pixels;

	public void run(String arg) {
		ImageProcessor primeIP = new ColorProcessor(1000, 1000);
		int R=400; 
		int xa=1000-200,xb=1000-500,ya=1000-500,yb=1000-200;
		
		int abscisses[]={xa,xb,xb,xa}; 
		int ordonnees[]={ya,yb,yb+R,ya+R}; 
		double alpha=0; 
		int pas=50; 
		double pasAlpha=Math.PI/(2*pas); 
		float red=(float)0.5; 
		float green=0;
		float blue=0; 
		float pasColor=(float)0.5/pas; 
		for(int i=0;i<pas;i++){
		Polygon pl=new Polygon(abscisses,ordonnees,4);
		primeIP.setColor(new Color(red,green,blue)); 
		primeIP.drawPolygon(pl); 
		primeIP.fillPolygon(pl);
		alpha=alpha+2*pasAlpha; 
		pasAlpha=pasAlpha*0.99;
		abscisses[2]=(int)(xb-R*Math.sin(alpha)); 
		abscisses[3]=(int)(xa-R*Math.sin(alpha)); 
		ordonnees[2]=(int)(yb-R*Math.cos(alpha)); 
		ordonnees[3]=(int)(ya-R*Math.cos(alpha));
		red+=pasColor; 
		green+=pasColor;
		blue+=pasColor; 
		}
		
		
		setProcessor("Livre", primeIP);
		show();
	}

	

}
